var mongoose = require('mongoose')

var db = require('../server/db')

var modelName = 'article'

var schema = new mongoose.Schema({
  type: String,
  title: String,
  desc: String,
  url: String,
  order: Number
}, {timestamp: true})


schema.statics.create = function (data, cb) {
  return new this(data).save(cb)
}
schema.statics.getAll = function (cb) {
  return this.find({}).sort({order: -1}).exec(cb)
}


var model = db.model(modelName, schema)


module.exports = model